SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vwtAgentes
AS
SELECT     dbo.tb_Agentes.idAgente AS ID, dbo.vwrTiposDeDocumento.Descripcion AS TipoDocumento, dbo.tb_Agentes.Documento, dbo.tb_Agentes.Apellido, 
                      dbo.tb_Agentes.Nombre, dbo.vwrSexo.Descripcion AS Sexo, dbo.tb_Agentes.CUIL, dbo.vwrEstadosCuil.Descripcion AS EstadoCUIL, dbo.tb_Agentes.Domicilio, 
                      dbo.vwrLocalidades.Descripcion AS Localidad, dbo.tb_Agentes.Telefono, dbo.tb_Agentes.Email, dbo.tb_Agentes.FechaNacimiento, dbo.tb_Agentes.LegajoDeInicial, 
                      dbo.tb_Agentes.LegajoDePrimaria, dbo.tb_Agentes.LegajoDeMedia, dbo.tb_Agentes.FechaAlta, dbo.tb_Agentes.FechaBaja, dbo.tb_Agentes.Baja, 
                      dbo.tb_Agentes.FechaCarga, dbo.vwrUsuarios.Descripcion AS NTUser
FROM         dbo.tb_Agentes INNER JOIN
                      dbo.vwrTiposDeDocumento ON dbo.tb_Agentes.TipoDocumento = dbo.vwrTiposDeDocumento.ID LEFT OUTER JOIN
                      dbo.vwrEstadosCuil ON dbo.tb_Agentes.EstadoCUIL = dbo.vwrEstadosCuil.Id LEFT OUTER JOIN
                      dbo.vwrSexo ON dbo.tb_Agentes.Sexo = dbo.vwrSexo.ID LEFT OUTER JOIN
                      dbo.vwrUsuarios ON dbo.tb_Agentes.NTUser = dbo.vwrUsuarios.ID LEFT OUTER JOIN
                      dbo.vwrLocalidades ON dbo.tb_Agentes.Localidad = dbo.vwrLocalidades.ID
GO
GRANT SELECT ON  [dbo].[vwtAgentes] TO [CentroDeDesignaciones]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [CertificacionesAdministracion]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [CertificacionesServicios]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [DepartamentoTecnicoContable]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [Direcciones De Nivel]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [Juntas]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [MCEEjecutivo]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [PersonalDocente]
DENY SELECT ([Domicilio]) ON [dbo].[vwtAgentes] TO [pregase]
DENY SELECT ([Telefono]) ON [dbo].[vwtAgentes] TO [pregase]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [RegistroTitulos]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [SaludLaboral]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [SoloVer]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [Subsidios]
GRANT SELECT ON  [dbo].[vwtAgentes] TO [SubsidiosConsulta]
GO
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[37] 4[25] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1 [56] 4 [18] 2))"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "tb_Agentes"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 240
               Right = 239
            End
            DisplayFlags = 280
            TopColumn = 32
         End
         Begin Table = "vwrTiposDeDocumento"
            Begin Extent = 
               Top = 6
               Left = 277
               Bottom = 84
               Right = 466
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrEstadosCuil"
            Begin Extent = 
               Top = 52
               Left = 642
               Bottom = 130
               Right = 831
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrSexo"
            Begin Extent = 
               Top = 6
               Left = 869
               Bottom = 84
               Right = 1058
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrUsuarios"
            Begin Extent = 
               Top = 206
               Left = 290
               Bottom = 304
               Right = 479
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "vwrLocalidades"
            Begin Extent = 
               Top = 84
               Left = 277
               Bottom = 177
               Right = 466
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
        ', 'USER', N'dbo', 'VIEW', N'vwtAgentes', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_DiagramPane2', N' Column = 1440
         Alias = 1395
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'USER', N'dbo', 'VIEW', N'vwtAgentes', NULL, NULL
GO
DECLARE @xp int
SELECT @xp=2
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'USER', N'dbo', 'VIEW', N'vwtAgentes', NULL, NULL
GO
